package com.onepower.core.utils;

import java.util.Collections;
import java.util.List;

public class ScoreUtils {

    /**
     * 平均数
     * @param scores
     * @return
     */
    public Double avgScore(List<Double> scores){
        Double sumScore = Double.valueOf(0);
        for (Double score : scores ){
            sumScore = sumScore + score;
        }
        return sumScore/scores.size();
    }

    /**
     * 求和
     * @param scores
     * @return
     */
    public Double sumScore(List<Double> scores){
        Double sumScore = Double.valueOf(0);
        for (Double score : scores ){
            sumScore = sumScore + score;
        }
        return sumScore;
    }

    /***
     * 去峰值求和
     * @param scores
     * @return
     */
    public Double removeTopSumScore(List<Double> scores){
        Collections.sort(scores);
        Double sumScore = Double.valueOf(0);
        for (int i=0;i<scores.size()-1;i++){
            sumScore = sumScore + scores.get(i);
        }
        return sumScore;
    }

    /***
     * 去峰值求平均
     * @param scores
     * @return
     */
    public Double removeTopAvgScore(List<Double> scores){
        Collections.sort(scores);
        Double sumScore = Double.valueOf(0);
        for (int i=0;i<scores.size()-1;i++){
            sumScore = sumScore + scores.get(i);
        }
        return sumScore/scores.size();
    }
}
